<?php
include('../../include/functions.inc.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Reposicion de Cheques</title>
        <script src="../../js/jquery.js" type="text/javascript"></script>
        <link href="../../bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
        <link href="../../css/ContentStyle.css" rel="stylesheet" type="text/css" />
        <link href="../../js/protocalendar/datepicker.css" rel="stylesheet" type="text/css" />
        <link href="../../css/tableorderer.css" rel="stylesheet" type="text/css" />
        <link href="../../js/dialog/dialog.2.0.css" rel="stylesheet" type="text/css" />
        <script>jQuery.noConflict();</script>
        <script src="../../bootstrap/js/bootstrap.js"></script>
        <script src="../../js/prototype.js" type="text/javascript"></script>
        <script src="../../js/jsvalidate.js" type="text/javascript"></script>
        <script src="../../js/protocalendar/prototype-date-extensions.js" type="text/javascript"></script>
        <script src="../../js/protocalendar/datepicker.js"  type="text/javascript"></script>
        <script src="../../js/TableOrderer.js" type="text/javascript"></script>
        <script src="../../js/dialog/dialog.2.0.js" type="text/javascript"></script>
        <script src="../../js/include.js" type="text/javascript"></script>
        <script src="../../bootstrap/js/bootstrap.js"></script>
        <style type="text/css">
            input,
            textarea{
                width: 300px;
            }
            select{
                width: 314px;
            }
        </style>
        <script type="text/javascript">
            showCheques=function(){
                var f=new Hash({tittle:'Listado de Cheques Activos',url:'lschekesRechas.php',callback:selCheke,
                    width:500,height:500});
                setList(null,f.toObject());
            }

            selCheke=function(s){
                $("NUMERO").value=s.NUMERO;
                $("MONTO").value=s.MONTO;
                $("NMONTO").value=s.MONTO;
                $("FACTURA").value=s.FACTURA;
                $("BANCO").value=s.BANCO;
                $("ID").value=s.ID_CHEQUE;
                $("FK_FACURA").value=s.ID_FACURA;
            }

            showCheque=function(c){
                if(c.value=="CHEQUE"){
                    $("nuevo").show();
                }else{
                    $("nuevo").hide();
                }
            }

            validCheke=function(){
                var error=new Array();
                if($F("REPOSICION")=="CHEQUE"){
                    if($F("NCHEQUE").empty()){
                        error.push([$("NCHEQUE"), "El numero del Cheque es requerido!"]);
                    }
                    if($F("FECHACOBRO").empty()){
                        error.push([$("FECHACOBRO"), "La fecha de cobro del cheque es requerida!"]);
                    }
                    if($F("NBANCO").empty()){
                        error.push([$("NBANCO"), "Seleccione un banco!"]);
                    }
                }
                if(error.size()>0){
                    return error.toArray();
                }
                return true;
            }

            var rsv;
            config=function(){
                $("nuevo").hide();
                rsv=new RSV({
                    formID: $(document.form),
                    errorFieldClass: "errorField",
                    rules: ["required,NUMERO,Selecciones un Cheque!",
                        "required,REPOSICION,Seleccione el tipo de Reposicion!",
                        "function,validCheke"],
                    displayType : "display-html",
                    errorHTMLItemBullet : "&#8212; ",
                    onCompleteHandler:function(){
                        waitMsg("Guardando...");
                        $('operation').value='s';
                        $(document.form).request({onComplete:function(r){
                                alert(r.responseText);
                                closeWait();
                                waitMsg("Reposicion finalizada!");
                                $(document.form).reset();
                                $("nuevo").hide();
                                closeWait();
                            }
                        });
                    }
                });
            }
            addOnLoad(config);
            var r=new Array()

        </script>
    </head>

    <body>
        <div id="tabs">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a>Cheque a Reponer</a>
                </li>
            </ul>
        </div>
        <div id="tabs-cont">
            <div id="rsvErrors"></div>
            <form id="form" name="form" method="GET" action="data.php">
                <input name="operation" type="hidden" id="operation" value="new" />
                <table class=""  width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <th scope="col" width="50%"></th>
                        <th valign="middle" width="50%" scope="col"><input name="GUARDAR" type="button" onclick="rsv.validate();" class="btn btn-info" value="Guardar" id="GUARDAR" /></th>
                    </tr>
                    <tr>
                        <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td width="15%">NO CHEQUE</td>
                                    <td width="85%">            <input name="NUMERO"  type="text" id="NUMERO" size="30" readonly="readonly" />
                                        <input name="buscar" onclick="showCheques()" type="button" class="btn btn-small" id="buscar"  value=".." />            </td>
                                </tr>
                                <tr>
                                    <td>MONTO</td>
                                    <td><input  name="MONTO" type="text" id="MONTO" readonly="readonly" size="30" /></td>
                                </tr>
                                <tr>5
                                    <td>FACTURA</td>
                                    <td><input name="FACTURA" readonly="readonly" type="text" id="FACTURA" size="30" /></td>
                                </tr>
                                <tr>
                                    <td>BANCO</td>
                                    <td>
                                        <input name="BANCO" readonly="readonly" type="text" id="BANCO" size="30" />
                                        <input type="hidden" id="ID" name="ID" />
                                        <input type="hidden" id="FK_FACURA" name="FK_FACURA" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>TIPO REPOSICION</td>
                                    <td><select name="REPOSICION" onchange="showCheque(this)"  id="REPOSICION">
                                            <option  selected="selected" value="">Seleccionar</option>
                                            <option value="EFECTIVO">EFECTIVO</option>
                                            <option value="CHEQUE">CHEQUE</option>
                                            <option value="TARJETA">TARJETA DEB/CRED</option>
                                            <option value="DEPOSITO" >DEPOSITO</option>
                                        </select>          </td>
                                </tr>
                                <tr>
                                    <td>CONCEPTO</td>
                                    <td><label>
                                            <textarea name="CONCEPTO" id="CONCEPTO" cols="45" rows="5"></textarea>
                                        </label></td>
                                </tr>

                            </table>      </td>
                    </tr>
                </table>
                <div id="nuevo" >
                    <table class=""  width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <th width="100%" scope="col"><legend>Nuevo Cheque</legend></th>
                        </tr>
                        <tr>
                            <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td width="25%">NUMERO</td>
                                        <td width="75%"><input name="NCHEQUE" type="text" id="NCHEQUE" size="30"  /></td>
                                    </tr>
                                    <tr>
                                        <td>MONTO</td>
                                        <td><input  name="NMONTO" readonly="readonly" type="text" id="NMONTO"  size="30" /></td>
                                    </tr>
                                    <tr>
                                        <td>BANCO</td>
                                        <td>
                                            <select name="NBANCO" id="NBANCO">
                                                <option  selected="selected" value="">Seleccionar</option>
                                                <option title="Banco Industrial, S.A." value="BI">Banco Industrial, S.A.</option>
                                                <option title="Banco G&T Continental, S.A." value="GYT">Banco G&T Continental, S.A.</option>
                                                <option title="Banco Agromercantil de Guatemala, S.A." value="BAM">BAM</option>
                                                <option title="Banco Reformador, S.A." value="REFORMADOR">Banco Reformador, S.A.</option>
                                                <option title="Banco Citibank de Guatemala, S.A." value="CITY">CITI</option>
                                                <option title="Banco de Desarrollo Rural, S.A." value="BanRural">BANRURAL</option>
                                                <option title="Banco Internacional, S.A." value="Internacional">INTERBANCO</option>
                                                <option title="Banco Promerica, S.A." value="Promerica">Banco Promerica, S.A.</option>
                                                <option title="Banco de Am�rica Central, S.A." value="BAC">BAC</option>
                                                <option title="El Cr�dito Hipotecario Nacional de Guatemala" value="CHN">CHN</option>
                                                <option title="Banco Inmobiliario, S.A." value="Inmobiliario">Banco Inmobiliario, S.A.</option>
                                                <option title="Primer Banco de Ahorro y Pr�stamo para la Vivienda Familiar, S.A." value="Vivibanco">VIVIBANCO</option>
                                                <option title="Banco de los Trabajadores" value="TRABAJADORES">Banco de los Trabajadores</option>
                                                <option title="Banco Ficohsa Guatemala, S.A." value="FICOHSA">Banco Ficohsa Guatemala, S.A.</option>
                                                <option title="Banco de Antigua, S.A." value="ANTIGUA">Banco de Antigua, S.A.</option>
                                                <option title="Banco de Cr�dito, S.A." value="CREDITO">Banco de Cr�dito, S.A.</option>
                                                <option title="Banco Azteca de Guatemala, S.A." value="AZTECA">Banco Azteca de Guatemala, S.A.</option>
                                                <option value="Otro">Otro</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>FECHA COBRO</td>
                                        <td><input name="FECHACOBRO" readonly="readonly" value="<?php echo date("Y-m-d"); ?>"
                                                   type="text" id="FECHACOBRO" size="30" />
                                        </td>
                                    </tr>

                                </table></td>
                        </tr>
                    </table>
                </div>
            </form>
        </div>
    </body>
</html>